package com.cmii.sjw.department.control.jsc.controller;

import com.cmii.sjw.department.control.jsc.model.params.SchoolInfoParams;
import com.cmii.sjw.department.control.jsc.service.IndustryEducationService;
import com.cmii.sjw.department.control.jsc.util.Result;
import com.cmii.sjw.department.control.jsc.vo.SchoolResponse;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * 产教联合Controller
 *
 * @author lizheng
 * @date 2025-2-13
 */
@RestController
@CrossOrigin
@RequestMapping("/education")
public class IndustryEducationController {

    @Resource
    private IndustryEducationService industryEducationService;

    /**
     * 产业名称列表
     *
     * @return 根据传入的区县参数查询
     * @author lizheng
     * @date 2025-2-13
     */
    @PostMapping("/list")
    public Result getIndustryNames(@RequestParam(required = false) String managementAreaName) {
        List<String> result ;
        if (managementAreaName != null && !managementAreaName.isEmpty()) {
            result = industryEducationService.getIndustryNamesByManagementArea(managementAreaName);
        } else {
            result = industryEducationService.getAllIndustryNames();
        }
        return Result.success(result);
    }

    /**
     * 根据产业名称查询对应学校以及地区
     *
     * @return 根据产业名称查询对应学校以及地区
     * @author lizheng
     * @date 2025-2-13
     */
    @PostMapping("/school")
    public Result<SchoolResponse> getSchoolsByIndustry(@RequestParam String industryName) {
        SchoolResponse schoolResponse = industryEducationService.getSchoolsByIndustryName(industryName);

        return Result.success(schoolResponse);
    }

    /**
     * 产教地图详细数据
     *
     * @param params
     * @return
     */
    @PostMapping("/industryEducationMapDetailed")
    public Result industryEducationMapDetailed(SchoolInfoParams params) {
        return industryEducationService.industryEducationMapDetailed(params);
    }
}
